import Axios from './axios'

// 加入购物车
export function addCar(userName,shopIid) {
    return Axios({
        url: '/shopCar/addCar',
        params: {
            userName,
            shopIid
        }
    })
  }

  // 查询购物车
  export function selectCar(userName) {
    return Axios({
        url: '/shopCar/selectCar',
        params: {
            userName
        }
    })
  }
  // 添加订单
  export function addOrder(list) {
      return Axios({
          url: '/shopCar/addOrder',
          params: {
            list
          }
      })
  }
  export function changeStatus(id) {
      return Axios({
          url: '/shopCar/updateOrder',
          params: {
              id
          }
      })
  }
  export function selectOrder(userName,type) {
    return Axios({
        url: '/shopCar/selectOrder',
        params: {
            userName,
            type
        }
    })
}
// 退款
export function refund(orderId,orderLineId) {
    return Axios({
        url: '/shopCar/refund',
        params: {
            orderId,
            orderLineId
        }
    })
}
// 生成订单二维码供用户使用门票
export function orderQRCode(codeContent) {
    return Axios({
        url: '/shopCar/userAndOrderLineQRCode',
        params: {
            codeContent
        }
    })
}
//   原本想把订单
export class Orders{
    constructor(array,totalPrice,totalNum,username){
        this.list = [];
        // array.forEach(element => {
        //     this.list.push(...new OrderLine(element));
        // });
        this.totalPrice = totalPrice;
        this.totalNum = totalNum;
        this.userName = username;
    }
}
export class OrderLine{
    constructor(obj){
        this.iid = obj.iid;
        this.realPrice = obj.realPrice;
        this.shopCount = obj.shopCount;
    }
}